/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.images;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Random;

/**
 * <p>Project: jse2204 - LineDemo
 * <p>Powered by webrx On 2022-09-26 16:39:34
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class LineDemo {
    public static void main(String[] args) throws Exception {


        int w = 800;
        int h = 800;
        BufferedImage src = new BufferedImage(w, h, 1);
        Random rand = new Random();

        Graphics2D g = src.createGraphics();
        //设置线条和文件的，抗锯齿（平滑）
        g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);

        g.setColor(Color.ORANGE);
        g.fillRect(0, 0, w, h);

        //1大圆
        g.setColor(Color.BLACK);
        g.fillArc(200, 200, 400, 400, 90, 180);
        g.setColor(Color.WHITE);
        g.fillArc(200, 200, 400, 400, 270, 180);

        //2小圆
        g.setColor(Color.BLACK);
        g.fillOval(300, 200, 200, 200);
        g.setColor(Color.WHITE);
        g.fillOval(300, 400, 200, 200);

        //3小圆 100
        g.setColor(Color.WHITE);
        g.fillOval(350, 250, 100, 100);
        g.setColor(Color.BLACK);
        g.fillOval(350, 450, 100, 100);

        /*
        for (int i = 0; i < 100; i++) {
            g.setStroke(new BasicStroke(rand.nextInt(15) + 1));
            g.setColor(new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256), rand.nextInt(256)));
            int x1 = rand.nextInt(w);
            int y1 = rand.nextInt(h);
            int x2 = rand.nextInt(w);
            int y2 = rand.nextInt(h);
            g.drawLine(x1, y1, x2, y2);
        }

         */

        //g.drawRect(10,10,100,80);
        //g.setColor(Color.RED);
        //g.fillRect(20,20,20,20);
        //g.drawRoundRect(120,120,50,50,30,30);
        //g.fillRoundRect(220,220,150,150,10,10);

        g.dispose();

        String imgs = "c:/abc/g1_logo.jpg";
        ImageIO.write(src, "jpg", new File(imgs));
        Runtime.getRuntime().exec("cmd /k start " + imgs);


    }
}
